package com.zyj.adapter;

import com.zyj.handler.HttpServletHandler;
import com.zyj.model.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 专门来处理HttpServletHandler处理器类型
 * <p>
 * 接口1：HttpServletHandler(高仿了Servlet的写法)
 * void handleRequest(req,resp);
 */
public class HttpServletHandlerAdapter implements HandlerAdapter {
    @Override
    public boolean supports(Object handler) {
        return (handler instanceof HttpServletHandler);
    }

    @Override
    public ModelAndView handleRequest(Object handler, HttpServletRequest req, HttpServletResponse resp) throws Exception {
        ((HttpServletHandler) handler).handleRequest(req, resp);
        return null;
    }
}
